import {
  ModalForm,
  ProFormText,


} from '@ant-design/pro-components';
import React from 'react';
import { editBusinessPage} from "@/services/wms-dev-tool/business-page-list";
import {message} from "antd";
import {useRequest} from "@@/plugin-request";

const UpdateForm = (props:any) => {
  const {run} = useRequest(editBusinessPage, {
    manual: true,
    onSuccess: () => {
      props.handleUpdateFormOpen(false);
      props.ok()
    },
    onError:(error)=>{
      message.error(error.message)
    }
  })
  return (
    <ModalForm
      initialValues={props.values}
      modalProps={{
        destroyOnClose: true
      }}
      title={<span>编辑页面</span>}
      width="400px"
      open={props.updateFormOpen}
      onOpenChange={props.handleUpdateFormOpen}
      onFinish={async (value) => {
        run({
          ...props.values,
          ...value
        });
      }}
    >
      <ProFormText
        name="name"
        label={<span>名称</span>}
        width="md"
        placeholder="请输入名称"
        rules={[
          {
            required: true,
            message: (<span>名称是必填项</span>),
          },
        ]}
      />
      <ProFormText
        name="code"
        width="md"
        disabled={true}
        label={<span>编码</span>}
        placeholder="请输入编码"
        rules={[
          {
            required: true,
            message: (<span>编码是必填项</span>),
          },
        ]}
      />
    </ModalForm>
  );
};

export default UpdateForm;
